using System;
using System.Configuration;
using System.Data.SqlClient;

public partial class GridInlineEditing : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void YuiGrid1_RowCreated(object sender, GridControl.grid.YuiGridRowCreatedEventArgs e)
    {
        SqlConnection con = new SqlConnection();
        con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        con.Open();
        string sql = "INSERT INTO TB_MOVIE (TITLE, RATING, VOTES, YEAR, GENRE) VALUES (@title, @rating, @votes, @year, @genre)";
        SqlCommand cmd = new SqlCommand(sql, con);
        String title = (string) e.DataItem["TITLE"];
        cmd.Parameters.Add(new SqlParameter("@title", title ?? ""));
        double? rating = (double?) e.DataItem["RATING"];
        cmd.Parameters.Add(new SqlParameter("@rating", rating ?? 0));
        int? votes = (int?) e.DataItem["VOTES"];
        cmd.Parameters.Add(new SqlParameter("@votes", votes ?? 0));
        int? year = (int?) e.DataItem["YEAR"];
        cmd.Parameters.Add(new SqlParameter("@year", year ?? 0));
        cmd.Parameters.Add(new SqlParameter("@genre", "test"));
        cmd.ExecuteNonQuery();
        con.Close();
    }
}
